package org.iori.luodan.servlet;

import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.iori.json.JSONHelper;
import org.iori.luodan.base.BaseLogicFactory;
import org.iori.luodan.logic.CategoryLogic;
import org.iori.luodan.base.BaseServlet;

public class GetCategoryListServlet extends BaseServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5526805316625062568L;
	
	private static CategoryLogic categoryLogic = BaseLogicFactory.getCategoryLogic();
    
	@Override
	protected String doExcute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		// currentPageを取得する
		int start_row = Integer.parseInt(request.getParameter("start_row").toString());
		int row_count = Integer.parseInt(request.getParameter("row_count").toString());
		
		ArrayList contentsList = categoryLogic.getCategoryInfo(start_row, row_count);
		
		response.setCharacterEncoding("utf-8");
		response.setContentType("application/json;charset=utf-8");
		JSONHelper.writeObject(response, contentsList);
		return null;
	}

}
